package edu.ufop.vaadin.jdbc.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import edu.ufop.vaadin.jdbc.ConnectionFactory;
import edu.ufop.vaadin.usuario.Aluno;

public class AlunoDao {
	private Connection connection;

	public AlunoDao() throws Exception{
		this.connection = new ConnectionFactory().getConnection();
	}
	
	public void adiciona(Aluno aluno){
		String sql = "insert into aluno" + "(nome,endereco,doc,telefone,email,usuario,senha,matricula)" + " values (?,?,?,?,?,?,?,?)";
		
		try{
			PreparedStatement stmt = connection.prepareStatement(sql);
			stmt.setString(1, aluno.getName());
			stmt.setString(2, aluno.getEndereco());
			stmt.setInt(3, aluno.getDoc());
			stmt.setString(4, aluno.getTelefone());
			stmt.setString(5, aluno.getEmail());
			stmt.setString(6, aluno.getUsuario());
			stmt.setString(7, aluno.getSenha());
			stmt.setInt(8, aluno.getMatricula());
			
			stmt.execute();
			stmt.close();
			
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
		
		
	}
	public Aluno pesquisa(Aluno aluno){
		
		
		return aluno;
		
		
	}
		

}
